

cd "G:\Dividends_II_RFS\Replication"


		
**************************************
**************** TABLES **************
**************************************
	


****************************************************************************************************************
*** 	TABLE 1: SUMMARY STATISTICS OF SAMPLE
****************************************************************************************************************

*use anon_descriptive_1, replace
// FILE IS NOT INCLUDED IN REPLCIATION PACKAGE //


global demo 	i_male age i_married customer_years i_employee i_civil_servant i_manager i_retired i_student ///
				 i_credit_card  i_depot i_savings_account i_property_loan 
	

* labels
*quietly do Do-Files/DIV2_Labels.do


eststo clear
eststo: estpost sum $demo if group == 0 
eststo: estpost sum $demo if (group == 1|group == 2)
eststo: estpost sum $demo if (group == 3|group == 4)
eststo: estpost sum $demo if group == 2			& finalsample==1
eststo: estpost sum $demo if group == 4			& finalsample==1


esttab , ///
			cells("mean(fmt(%10.2fc) pattern(1 1 1 1 1))") label ///
				mgroups("Sampled" ///
						"Participated", ///
						pattern(1 0 0 1 0) ///
				 prefix(\multicolumn{@span}{c}{) suffix(}) ///
				span erepeat(\cmidrule(lr){@span})) ///
				mtitles("Zero touch" "Placebo" ///	
						"Reinvest" ///
						"Placebo" ///
						"Reinvest" prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
			nonumbers  ///
			refcat(i_employee "" , nolabel) ///
			booktabs replace width(\hsize) 

	
esttab using "tables\table1_a_demographics.tex", ///
			cells("mean(fmt(%10.2fc) pattern(1 1 1 1 1))") label ///
				mgroups("Sampled" ///
						"Participated", ///
						pattern(1 0 0 1 0) ///
				 prefix(\multicolumn{@span}{c}{) suffix(}) ///
				span erepeat(\cmidrule(lr){@span})) ///
				mtitles("Zero touch" "Placebo" ///	
						"Reinvest" ///
						"Placebo" ///
						"Reinvest" prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
			nonumbers  ///
			refcat(i_employee "" , nolabel) ///
			booktabs replace width(\hsize) 
		
		
	

/// Table 2: Account balances, portfolio and trades
*use anon_descriptive_2, replace 
// FILE IS NOT INCLUDED IN REPLCIATION PACKAGE // 




global fin 			wealth portval aum_credit aum_deposit  
global portfolio 	fund_participation etf_participation ///
					weight_equity weight_fi weight_stocks weight_fund weight_etfs home_share ///
					weight_dividend_secs weight_dividend_stocks weight_dividend_funds ///
					no_securities no_stock no_funds  hhi monthly_trades total_trades
				
* labels
*quietly do Do-Files/DIV2_Labels.do

eststo clear
eststo: estpost sum $fin $portfolio if group == 0
eststo: estpost sum $fin $portfolio if (group == 1|group == 2) 
eststo: estpost sum $fin $portfolio if (group == 3|group == 4) 
eststo: estpost sum $fin $portfolio if group == 2 	& finalsample==1
eststo: estpost sum $fin $portfolio if group == 4	& finalsample==1



esttab , ///
			cells("mean(fmt(%10.2fc) pattern(1 1 1 1 1))") label ///
				mgroups("Sampled" ///
						"Participated", ///
						pattern(1 0 0 1 0) ///
				 prefix(\multicolumn{@span}{c}{) suffix(}) ///
				span erepeat(\cmidrule(lr){@span})) ///
				mtitles("Zero touch" "Placebo" ///	
						"Reinvest" ///
						"Placebo" ///
						"Reinvest" prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
			nonumbers  ///
			refcat(fund_participation "" weight_equity "" no_securities "", nolabel) ///
		booktabs replace width(\hsize)


esttab using "tables\table1_b_holdings.tex", ///
			cells("mean(fmt(%10.2fc) pattern(1 1 1 1 1))") label ///
					mgroups("Sampled" ///
						"Participated", ///
						pattern(1 0 0 1 0) ///
				 prefix(\multicolumn{@span}{c}{) suffix(}) ///
				span erepeat(\cmidrule(lr){@span})) ///
				mtitles("Zero touch" "Placebo" ///	
						"Reinvest" ///
						"Placebo" ///
						"Reinvest" prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
			nonumbers  ///
			refcat(fund_participation "" weight_equity "" no_securities "", nolabel) ///
		booktabs replace width(\hsize)
				
	
		
		
/// Table 3: Trades detailed
* anon_descriptive_3, replace
// FILE IS NOT INCLUDED IN REPLCIATION PACKAGE //



global trades 		total_trades monthly_trades monthly_purchases monthly_sales ///
					months_traded months_purchased months_sold ///
					m_trade_vol m_purchase_vol m_sale_vol 

					
* labels
*quietly do Do-Files/DIV2_Labels.do

eststo clear
eststo: estpost sum $trades if group == 0
eststo: estpost sum $trades if (group == 1|group == 2)
eststo: estpost sum $trades if (group == 3|group == 4)
eststo: estpost sum $trades if group == 2		& finalsample==1
eststo: estpost sum $trades if group == 4		& finalsample==1


esttab , ///
			cells("mean(fmt(%10.2fc) pattern(1 1 1 1 1))") label ///
				mgroups("Sampled" ///
						"Participated", ///
						pattern(1 0 0 1 0) ///
				 prefix(\multicolumn{@span}{c}{) suffix(}) ///
				span erepeat(\cmidrule(lr){@span})) ///
				mtitles("Zero touch" "Placebo" ///	
						"Reinvest" ///
						"Placebo" ///
						"Reinvest" prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
			nonumbers  ///
		refcat(months_traded "" m_trade_vol, nolabel) ///
		booktabs replace width(\hsize)

esttab using "tables\table1_c_trades.tex", ///
			cells("mean(fmt(%10.2fc) pattern(1 1 1 1 1))") label ///
				mgroups("Sampled" ///
						"Participated", ///
						pattern(1 0 0 1 0) ///
				 prefix(\multicolumn{@span}{c}{) suffix(}) ///
				span erepeat(\cmidrule(lr){@span})) ///
				mtitles("Zero touch" "Placebo" ///	
						"Reinvest" ///
						"Placebo" ///
						"Reinvest" prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
			nonumbers  ///
		refcat(months_traded "" m_trade_vol, nolabel) ///
		booktabs replace width(\hsize)
		
		
		
		




**************************************
* TABLE 2: Planned reinvestment decisions: survey responses
**************************************

use anon_survey, replace
drop post
gen post = (year==2021)
gen treated_post = treated*post


global covar "age i_male i_credit_card i_savings_account i_property_loan   i_married i_retired i_student   DIV_amount_this_year DIV_amount_last_year monthly_holdings"
label var DIV_amount_this_year "Dividends recieved 2021"
label var DIV_amount_last_year "Dividends recieved 2020"
label var monthly_holdings 	   "Portfolio holdings"
label var i_savings_account 	   "Savings account"


		est clear
		eststo: reg MPR_dum						treated_post treated	post  			, robust cluster(rfs_id)
		estadd local surveyfe "N"
		estadd local control "N"
			
		eststo: areg MPR_dum					treated_post treated	post   $covar 	, absorb(survey_date) robust  cluster(rfs_id)
		estadd local surveyfe "Y"
		estadd local control "Y"
	
		eststo: reg MPR_t						treated_post treated	post  			, robust cluster(rfs_id)
		estadd local surveyfe "N"
		estadd local control "N"
			
		eststo: areg MPR_t						treated_post treated	post   $covar 	, absorb(survey_date) robust  cluster(rfs_id)
		estadd local surveyfe "Y"
		estadd local control "Y"
		
		esttab  , ///
					replace b(2) se star(* 0.10 ** 0.05 *** 0.01) nogaps label ///
					drop(_cons ) stats(surveyfe  r2 N , fmt(%15.3fc %15.3fc %15.0fc) ///
					labels("Survey date FE"  "R-squared" "Observations")) ///
					varlabels(treated "Reinvestment treatment" treated_post "Treatment $\times$ Post" post "Post")
					
			
			esttab using tables/Table2a.tex  ,  ///
					replace b(2) se star(* 0.10 ** 0.05 *** 0.01) nogaps label ///
					drop(_cons ) stats(surveyfe  r2 N, fmt(%15.3fc %15.3fc %15.0fc) ///
					labels("Survey date FE"  "R-squared" "Observations"))  nonotes  ///
					mgroups("\shortstack{Marginal propensity to reinvest}" ///
							"\shortstack{Fraction reinvested (\%)}"	 , ///
							pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) ///
							span erepeat(\cmidrule(lr){@span})) ///
					width(\hsize) ///
					booktabs ///
					obslast nomtitles ///
					refcat(1.group "", nolabel) ///
					varlabels(treated "Reinvestment treatment" treated_post "Treatment $\times$ Post" post "Post")
		
	est clear	
	
		eststo: reg i_reinvestment_fund			treated 	 	if year==2021	, robust
		estadd local surveyfe "N"
		estadd local control "N"
		
		eststo: areg i_reinvestment_fund		treated  $covar if year==2021	, absorb(survey_date) robust cluster(rfs_id)
		estadd local surveyfe "Y"
		estadd local control "Y"
		
		eststo: reg i_cta_reinvestment_wish		treated 	 	if year==2021	, robust
		estadd local surveyfe "N"
		estadd local control "N"
		
		eststo: areg i_cta_reinvestment_wish	treated  $covar if year==2021	, absorb(survey_date) robust cluster(rfs_id)
		estadd local surveyfe "Y"
		estadd local control "Y"
			

			esttab  , ///
					replace b(2) se star(* 0.10 ** 0.05 *** 0.01) nogaps label ///
					drop(_cons ) stats(surveyfe  r2 N , fmt(%15.3fc %15.3fc %15.0fc) ///
					labels("Survey date FE"  "R-squared" "Observations")) ///
					varlabels(treated "Reinvestment treatment")	
					
			
			esttab using tables/Table2b.tex  ,  ///
					replace b(2) se star(* 0.10 ** 0.05 *** 0.01) nogaps label ///
					drop(_cons) stats(surveyfe  r2 N, fmt(%15.3fc %15.3fc %15.0fc) ///
					labels("Survey date FE"  "R-squared" "Observations"))  nonotes  ///
					mgroups("\shortstack{Reinvestment fund preference}" ///
							"\shortstack{Auto reinvest preference}"  , ///
							pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) ///
							span erepeat(\cmidrule(lr){@span})) ///
					width(\hsize) ///
					booktabs ///
					obslast nomtitles ///
					refcat(1.group "", nolabel) ///
					varlabels(treated "Reinvestment treatment")	
					
					
**************************************
* TABLE 3: Reinvestment in the field
**************************************

use anon_mainsample, replace
sort rfs_id wofd
xtset rfs_id wofd

est clear


local divvar "dividends_ws18_21"

eststo e1:   reghdfe transaction_volume       c.dividends_cutoff##treated##post 	monthly_holdings	, abs(wofd 		 ) cluster(rfs_id)
	estadd local divfe "N"
	estadd local control "Y"
eststo e1f:  reghdfe transaction_volume       c.dividends_cutoff##treated##post 	monthly_holdings	, abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"

eststo e3:   reghdfe transaction_volume       c.`divvar'##treated##post	c.dividends_notws18_21##treated##post 	monthly_holdings	, abs(wofd 		 ) cluster(rfs_id)
	estadd local divfe "N"
	estadd local control "Y"
eststo e3f:  reghdfe transaction_volume       c.`divvar'##treated##post	c.dividends_notws18_21##treated##post   monthly_holdings	, abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"

	

esttab  ,    nobaselevels  interaction(" $\times$ ")style(tex) ///
	rename(1.treated#1.post#c.dividends_notws18_21 	div_not	1.treated#1.post#c.dividends_cutoff div_all 1.treated#1.post#c.`divvar' div_season) ///
	keep(div_all div_season div_not) noomit  replace b(2) se star(* 0.10 ** 0.05 *** 0.01)  varwidth(60) 	///
	varlabels(div_season "Dividends (Season) $\times$ Treatment $\times$ Post" ///
			div_not "Dividends (Other) $\times$ Treatment $\times$ Post" ///
								 div_all "Dividends $\times$ Treatment $\times$ Post"  )
					
	
esttab    using tables/Table3a.tex,   ///	
	replace b(2) se star(* 0.10 ** 0.05 *** 0.01) nogaps label  substitute(_ _) ///
					rename(1.treated#1.post#c.dividends_notws18_21 	div_not	1.treated#1.post#c.dividends_cutoff div_all 1.treated#1.post#c.`divvar' div_season) ///
					keep(div_all div_season div_not)  noomit  ///
					stats(divfe control r2 N , fmt(%15.2fc %15.2fc %15.2fc %15.0fc %15.2fc) ///
					labels("Individual FE" "Controls" "R-squared" "Observations" "Preperiod mean y" "Preperiod mean x"  )) nonotes  ///
					mgroups("\shortstack{Net transactions}", pattern(1 0 0 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) ///
							span erepeat(\cmidrule(lr){@span})) ///
							booktabs ///
					obslast nomtitles ///
					width(\hsize) ///
					refcat(1.group "", nolabel) ///
					varlabels(div_season "$ Dividends_{Season} \times Treatment \times Post$" ///
							  div_not "$ Dividends_{Other} \times Treatment \times Post$" ///
							  div_all "$ Dividends_{All} \times Treatment \times Post$" )

		
	

use anon_fullsample, replace
sort rfs_id wofd
xtset rfs_id wofd
	

local divvar "dividends_ws18_21"

est clear
eststo e1:   reghdfe transaction_volume       c.dividends_cutoff##treated##post 	monthly_holdings	, abs(wofd 		 ) cluster(rfs_id)
	estadd local divfe "N"
	estadd local control "Y"
eststo e1f:  reghdfe transaction_volume       c.dividends_cutoff##treated##post 	monthly_holdings	, abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"

eststo e3:   reghdfe transaction_volume       c.`divvar'##treated##post	c.dividends_notws18_21##treated##post 	monthly_holdings	, abs(wofd 		 ) cluster(rfs_id)
	estadd local divfe "N"
	estadd local control "Y"
eststo e3f:  reghdfe transaction_volume       c.`divvar'##treated##post	c.dividends_notws18_21##treated##post   monthly_holdings	, abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"


esttab  ,    nobaselevels  interaction(" $\times$ ")style(tex) ///
	rename(1.treated#1.post#c.dividends_notws18_21 	div_not	1.treated#1.post#c.dividends_cutoff div_all 1.treated#1.post#c.`divvar' div_season) ///
	keep(div_all div_season div_not) noomit  replace b(2) se star(* 0.10 ** 0.05 *** 0.01)  varwidth(60) 	///
	varlabels(div_season "Dividends (Season) $\times$ Treatment $\times$ Post" ///
			div_not "Dividends (Other) $\times$ Treatment $\times$ Post" ///
								 div_all "Dividends $\times$ Treatment $\times$ Post"  )	
	
esttab    using tables/Table3b.tex,   ///	
	replace b(2) se star(* 0.10 ** 0.05 *** 0.01) nogaps label  substitute(_ _) ///
					rename(1.treated#1.post#c.dividends_notws18_21 	div_not	1.treated#1.post#c.dividends_cutoff div_all 1.treated#1.post#c.`divvar' div_season) ///
					keep(div_all div_season div_not)  noomit  ///
					stats(divfe control r2 N , fmt(%15.2fc %15.2fc %15.2fc %15.0fc %15.2fc) ///
					labels("Individual FE" "Controls" "R-squared" "Observations" "Preperiod mean y" "Preperiod mean x"  )) nonotes  ///
					mgroups("\shortstack{Net transactions}", pattern(1 0 0 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) ///
							span erepeat(\cmidrule(lr){@span})) ///
							booktabs ///
					obslast nomtitles ///
					width(\hsize) ///
					refcat(1.group "", nolabel) ///
					varlabels(div_season "$ Dividends_{Season} \times Treatment \times Post$" ///
							  div_not "$ Dividends_{Other} \times Treatment \times Post$" ///
							  div_all "$ Dividends_{All} \times Treatment \times Post$" )
	
	
	

************************************************************************************************************************************
* TABLE IV: Further eviende on the MPR
************************************************************************************************************************************
cls
use anon_mainsample, replace
sort rfs_id wofd
xtset rfs_id wofd

est clear

local divvar "dividends_ws18_21"

	eststo e2:	reghdfe transaction_volume  			 	c.`divvar'##treated##post  c.dividends_notws18_21##treated##post monthly_holdings , abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"
			
	eststo e3:	reghdfe buy_transaction_volume_nw  			c.`divvar'##treated##post  c.dividends_notws18_21##treated##post monthly_holdings   , abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"
	
	eststo e4:	reghdfe sell_transaction_volume_nw  			c.`divvar'##treated##post  c.dividends_notws18_21##treated##post monthly_holdings  , abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"


	
esttab   e2 e3 e4 ,    nobaselevels  interaction(" $\times$ ")style(tex) ///
			rename(1.treated#1.post#c.dividends_notws18_21 	div_not 	1.treated#1.post#c.`divvar' div_season) ///
			keep(div_not div_season) noomit  replace b(2) se star(* 0.10 ** 0.05 *** 0.01)  varwidth(60) 	///
						varlabels(div_season "Dividends (Season) $\times$ Treatment $\times$ Post" ///
						 div_all "Dividends $\times$ Treatment $\times$ Post"  )
							 
esttab    e2 e3 e4  using tables/Table3a.tex ,  ///
					replace b(2) se star(* 0.10 ** 0.05 *** 0.01) nogaps label substitute(_ _)  ///
					rename(1.treated#1.post#c.dividends_notws18_21 	div_not  1.treated#1.post#c.`divvar' div_season) ///
					keep(div_not div_season)  noomit  ///
					stats(divfe control r2 N , fmt(%15.2fc %15.2fc %15.2fc %15.0fc %15.2fc) ///
					labels("Individual FE" "Controls" "R-squared" "Observations" "Preperiod mean y" "Preperiod mean x"  )) nonotes  ///
					mgroups("\shortstack{Net transactions}" ///
							"\shortstack{Purchases}" "\shortstack{Sales}", ///
							pattern(1 1 1 ) prefix(\multicolumn{@span}{c}{) suffix(}) ///
							span erepeat(\cmidrule(lr){@span})) ///
					width(\hsize) ///
					booktabs ///
					obslast nomtitles ///
					refcat(1.group "", nolabel) ///
					varlabels(div_season "$ Dividends_{Season} \times Treatment \times Post$" ///
							  div_not "$ Dividends_{Other} \times Treatment \times Post$" )


							  
* Panel B, Cumulative estimates							  
			 
use anon_mainsample, replace
sort rfs_id wofd
xtset rfs_id wofd


gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen cumu_b = 0
gen cumu_se = 0
gen cumu_bN = 0
gen cumu_seN = 0
sort rfs_id wofd


local divvar "dividends_ws18_21"

	reghdfe transaction_volume    l(0/4).c.`divvar'##treated##post 	l(0/4).c.dividends_notws18_21##treated##post 	monthly_holdings, abs(wofd rfs_id) cluster(rfs_id)
	
	*season
		local c0 = _b[1.treated#1.post#c.`divvar']
		forvalues x = 1/4 {
			local c`x' = _b[1.treated#1.post#cL`x'.`divvar']
		}
		replace cumu_b = `c0' if horizon == 0
		replace cumu_b = `c0' + `c1' if horizon == 1
		replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
		replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
		replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
			
		local c0 "_b[1.post#c.`divvar'#1.treated]"
		forvalues x = 1/4 {
			local c`x' "_b[1.post#cL`x'.`divvar'#1.treated]"
		}	
		local loop `c0'
		
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
			
		forvalues x = 0/3 {
			local g = `x'+1
			local loop `loop' + `c`g''	
			test `loop' = 0
			replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
		}

			local prestars1 = ""
			 if r(p) <= 0.1 local prestars1 = "*"  
			 if r(p) <= 0.05 local prestars1 = "**"
			 if r(p) <= 0.01 local prestars1 = "***"
		
		replace cumu_se = abs(cumu_se)
		
		
		
	
	* div other	
		local c0 = _b[1.treated#1.post#c.dividends_notws18_21]
		forvalues x = 1/4 {
			local c`x' = _b[1.treated#1.post#cL`x'.dividends_notws18_21]
		}
		replace cumu_bN = `c0' if horizon == 0
		replace cumu_bN = `c0' + `c1' if horizon == 1
		replace cumu_bN = `c0' + `c1' + `c2' if horizon == 2
		replace cumu_bN = `c0' + `c1' + `c2' + `c3' if horizon == 3
		replace cumu_bN = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
			
		local c0 "_b[1.post#c.dividends_notws18_21#1.treated]"
		forvalues x = 1/4 {
			local c`x' "_b[1.post#cL`x'.dividends_notws18_21#1.treated]"
		}	
		local loop `c0'
		
		test `loop' = 0
		replace cumu_seN = cumu_bN/sqrt(r(F)) if horizon == 0
				
		forvalues x = 0/3 {
			local g = `x'+1
			local loop `loop' + `c`g''	
			test `loop' = 0
			replace cumu_seN = cumu_bN/sqrt(r(F)) if horizon == `g'
		}

			local prestars2 = ""
			 if r(p) <= 0.1 local prestars2 = "*"  
			 if r(p) <= 0.05 local prestars2 = "**"
			 if r(p) <= 0.01 local prestars2 = "***"
		
		replace cumu_seN = abs(cumu_seN)
	
	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"
	sum cumu_bN cumu_seN if horizon==4
	di "`prestars2'"	
	
	
	
	
* purchases	

use anon_mainsample, replace
sort rfs_id wofd
xtset rfs_id wofd


gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen cumu_b = 0
gen cumu_se = 0
gen cumu_bN = 0
gen cumu_seN = 0
sort rfs_id wofd

local divvar "dividends_ws18_21"

	reghdfe buy_transaction_volume_nw    l(0/4).c.`divvar'##treated##post l(0/4).c.dividends_notws18_21##treated##post monthly_holdings, abs(wofd rfs_id) cluster(rfs_id)
		
	*season
		local c0 = _b[1.treated#1.post#c.`divvar']
		forvalues x = 1/4 {
			local c`x' = _b[1.treated#1.post#cL`x'.`divvar']
		}
		replace cumu_b = `c0' if horizon == 0
		replace cumu_b = `c0' + `c1' if horizon == 1
		replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
		replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
		replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
			
		local c0 "_b[1.post#c.`divvar'#1.treated]"
		forvalues x = 1/4 {
			local c`x' "_b[1.post#cL`x'.`divvar'#1.treated]"
		}	
		local loop `c0'
		
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
			
		forvalues x = 0/3 {
			local g = `x'+1
			local loop `loop' + `c`g''	
			test `loop' = 0
			replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
		}

			local prestars1 = ""
			 if r(p) <= 0.1 local prestars1 = "*"  
			 if r(p) <= 0.05 local prestars1 = "**"
			 if r(p) <= 0.01 local prestars1 = "***"
		
		replace cumu_se = abs(cumu_se)
		
		
		
	
	* div other	
		local c0 = _b[1.treated#1.post#c.dividends_notws18_21]
		forvalues x = 1/4 {
			local c`x' = _b[1.treated#1.post#cL`x'.dividends_notws18_21]
		}
		replace cumu_bN = `c0' if horizon == 0
		replace cumu_bN = `c0' + `c1' if horizon == 1
		replace cumu_bN = `c0' + `c1' + `c2' if horizon == 2
		replace cumu_bN = `c0' + `c1' + `c2' + `c3' if horizon == 3
		replace cumu_bN = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
			
		local c0 "_b[1.post#c.dividends_notws18_21#1.treated]"
		forvalues x = 1/4 {
			local c`x' "_b[1.post#cL`x'.dividends_notws18_21#1.treated]"
		}	
		local loop `c0'
		
		test `loop' = 0
		replace cumu_seN = cumu_bN/sqrt(r(F)) if horizon == 0
				
		forvalues x = 0/3 {
			local g = `x'+1
			local loop `loop' + `c`g''	
			test `loop' = 0
			replace cumu_seN = cumu_bN/sqrt(r(F)) if horizon == `g'
		}

			local prestars2 = ""
			 if r(p) <= 0.1 local prestars2 = "*"  
			 if r(p) <= 0.05 local prestars2 = "**"
			 if r(p) <= 0.01 local prestars2 = "***"
		
		replace cumu_seN = abs(cumu_seN)
	
	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"
	sum cumu_bN cumu_seN if horizon==4
	di "`prestars2'"	
	
	
* sales	
	
use anon_mainsample, replace
sort rfs_id wofd
xtset rfs_id wofd


gen horizon = -4
replace horizon = horizon[_n-1] + 1 if horizon[_n - 1] <= 3
egen tag = tag(horizon)
gen cumu_b = 0
gen cumu_se = 0
gen cumu_bN = 0
gen cumu_seN = 0

sort rfs_id wofd


local divvar "dividends_ws18_21"

	reghdfe sell_transaction_volume_nw    l(0/4).c.`divvar'##treated##post l(0/4).c.dividends_notws18_21##treated##post monthly_holdings, abs(wofd rfs_id) cluster(rfs_id)
		
	*season
		local c0 = _b[1.treated#1.post#c.`divvar']
		forvalues x = 1/4 {
			local c`x' = _b[1.treated#1.post#cL`x'.`divvar']
		}
		replace cumu_b = `c0' if horizon == 0
		replace cumu_b = `c0' + `c1' if horizon == 1
		replace cumu_b = `c0' + `c1' + `c2' if horizon == 2
		replace cumu_b = `c0' + `c1' + `c2' + `c3' if horizon == 3
		replace cumu_b = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
			
		local c0 "_b[1.post#c.`divvar'#1.treated]"
		forvalues x = 1/4 {
			local c`x' "_b[1.post#cL`x'.`divvar'#1.treated]"
		}	
		local loop `c0'
		
		test `loop' = 0
		replace cumu_se = cumu_b/sqrt(r(F)) if horizon == 0
			
		forvalues x = 0/3 {
			local g = `x'+1
			local loop `loop' + `c`g''	
			test `loop' = 0
			replace cumu_se = cumu_b/sqrt(r(F)) if horizon == `g'
		}

			local prestars1 = ""
			 if r(p) <= 0.1 local prestars1 = "*"  
			 if r(p) <= 0.05 local prestars1 = "**"
			 if r(p) <= 0.01 local prestars1 = "***"
		
		replace cumu_se = abs(cumu_se)
		
		
	
	* div other 	
		local c0 = _b[1.treated#1.post#c.dividends_notws18_21]
		forvalues x = 1/4 {
			local c`x' = _b[1.treated#1.post#cL`x'.dividends_notws18_21]
		}
		replace cumu_bN = `c0' if horizon == 0
		replace cumu_bN = `c0' + `c1' if horizon == 1
		replace cumu_bN = `c0' + `c1' + `c2' if horizon == 2
		replace cumu_bN = `c0' + `c1' + `c2' + `c3' if horizon == 3
		replace cumu_bN = `c0' + `c1' + `c2' + `c3' + `c4'  if horizon == 4
			
		local c0 "_b[1.post#c.dividends_notws18_21#1.treated]"
		forvalues x = 1/4 {
			local c`x' "_b[1.post#cL`x'.dividends_notws18_21#1.treated]"
		}	
		local loop `c0'
		
		test `loop' = 0
		replace cumu_seN = cumu_bN/sqrt(r(F)) if horizon == 0
				
		forvalues x = 0/3 {
			local g = `x'+1
			local loop `loop' + `c`g''	
			test `loop' = 0
			replace cumu_seN = cumu_bN/sqrt(r(F)) if horizon == `g'
		}

			local prestars2 = ""
			 if r(p) <= 0.1 local prestars2 = "*"  
			 if r(p) <= 0.05 local prestars2 = "**"
			 if r(p) <= 0.01 local prestars2 = "***"
		
		replace cumu_seN = abs(cumu_seN)
	
	di "COVAR FOR TABLE"
	sum cumu_b cumu_se if horizon==4
	di "`prestars1'"
	sum cumu_bN cumu_seN if horizon==4
	di "`prestars2'"	



***************************************
* Table V: Dividend litearcy
***************************************

* Panel A, survey behavior
use anon_survey, replace
sort rfs_id wofd

drop post
gen post = (year==2021)
gen treated_post = treated*post

keep if treated==1

global covar "age i_male i_credit_card i_savings_account i_property_loan i_married i_retired i_student  DIV_amount_this_year DIV_amount_last_year"
label var DIV_amount_this_year "Dividends recieved 2021"
label var DIV_amount_last_year "Dividends recieved 2020"

capture drop learned_new_post
capture drop learned_new
capture drop dividends_post

gen lowest_lit = (quiz_literacy==1)
gen informative = (feedback_informative>=6)
gen learned_new = (feedback_learned_new>=5)

keep if year == 2020

		est clear

			eststo: reg MPR_dif lowest_lit					, robust cluster(rfs_id)
			estadd local surveyfe "N"
			estadd local control "N"
		
			eststo: areg MPR_dif lowest_lit			$covar	, robust cluster(rfs_id) abs(survey_date)
			estadd local surveyfe "Y"
			estadd local control "Y"
		
			eststo: reg MPR_dif informative					, robust cluster(rfs_id)
			estadd local surveyfe "N"
			estadd local control "N"
		
			eststo: areg MPR_dif informative		$covar	, robust cluster(rfs_id) abs(survey_date)
			estadd local surveyfe "Y"
			estadd local control "Y"
			
			eststo: reg MPR_dif learned_new					, robust cluster(rfs_id)
			estadd local surveyfe "N"
			estadd local control "N"
		
			eststo: areg MPR_dif learned_new		$covar	, robust cluster(rfs_id) abs(survey_date)
			estadd local surveyfe "Y"
			estadd local control "Y"
		
		
				esttab  , ///
					replace b(2) se star(* 0.10 ** 0.05 *** 0.01) nogaps label ///
					drop(_cons ) stats(surveyfe control r2 N , fmt(%15.3fc %15.3fc %15.2fc %15.0fc) ///
					labels("Survey date FE" "Controls" "R-squared" "Observations")) ///
					order(learned_new lowest_lit informative) ///
					varlabels(lowest_lit "Low literacy" learned_new "Learned new" informative "Informative")	
										
					
			esttab using tables/Table5a.tex  ,  ///
					replace b(2) se star(* 0.10 ** 0.05 *** 0.01) nogaps label ///
					keep(learned_new informative lowest_lit) stats(surveyfe control r2 N, fmt(%15.3fc %15.3fc %15.2fc  %15.0fc) ///
					labels("Survey date FE" "Controls" "R-squared" "Observations"))  nonotes  ///
					mgroups("\shortstack{Change in MPR}" , ///
							pattern(1 0 0 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) ///
							span erepeat(\cmidrule(lr){@span})) ///
					booktabs ///
					width(\hsize) ///
					obslast nomtitles ///
					refcat(1.group "", nolabel) ///
					order(lowest_lit informative learned_new  ) ///
					varlabels(lowest_lit "Low literacy" learned_new "Learned new" informative "Informative")	

					
					
					
					
					

* Panel B, field behavior

cls	

use anon_mainsample, replace
sort rfs_id wofd
xtset rfs_id wofd

capture drop learned_new
capture drop lowest_lit
capture drop informative

gen lowest_lit = (quiz_literacy==1)
gen informative = (feedback_informative>=6)
gen learned_new = (feedback_learned_new>=5)
gen learned_most = (feedback_learned_new==7)


local divvar "dividends_ws18_21"


	est clear
	
	
	* net
	eststo:	reghdfe transaction_volume  		 	lowest_lit##c.`divvar'##post lowest_lit##c.dividends_notws18_21##post	monthly_holdings	   , abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"

	
	eststo:	reghdfe transaction_volume  		 	informative##c.`divvar'##post informative##c.dividends_notws18_21##post	monthly_holdings  , abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"


	eststo:	reghdfe transaction_volume  		 	learned_new##c.`divvar'##post learned_new##c.dividends_notws18_21##post	monthly_holdings    , abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"
	
	
* buy	
	eststo:	reghdfe buy_transaction_volume_nw  		 	lowest_lit##c.`divvar'##post lowest_lit##c.dividends_notws18_21##post	monthly_holdings	   , abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"

		
	eststo:	reghdfe buy_transaction_volume_nw  		 	informative##c.`divvar'##post informative##c.dividends_notws18_21##post	monthly_holdings   , abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"
	
	
	eststo:	reghdfe buy_transaction_volume_nw  		 	learned_new##c.`divvar'##post learned_new##c.dividends_notws18_21##post	monthly_holdings    , abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"



					
esttab using tables/Table5b.tex,  ///
					replace b(2) se star(* 0.10 ** 0.05 *** 0.01) nogaps label substitute(_ _)  ///
					keep(1.learned_new#1.post#c.`divvar' 1.lowest_lit#1.post#c.`divvar' 1.informative#1.post#c.`divvar')  stats(divfe control r2 N , fmt(%15.2fc %15.2fc %15.2fc %15.0fc %15.2fc) ///
					labels("Individual FE" "Controls" "R-squared" "Observations" "Preperiod mean y" "Preperiod mean x"  )) nonotes  ///
					mgroups("\shortstack{Net transactions}" ///
							"\shortstack{Purchases}", ///
							pattern(1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) ///
							span erepeat(\cmidrule(lr){@span})) ///
					width(\hsize) ///
					booktabs ///
					obslast nomtitles ///
					refcat(1.group "", nolabel) order(1.lowest_lit#1.post#c.`divvar'  1.informative#1.post#c.`divvar'  1.learned_new#1.post#c.`divvar') ///
					varlabels(1.learned_new#1.post#c.`divvar' "\small{$ Dividends_{Season} \times Learned \, new \times Post$}" ///
							  1.lowest_lit#1.post#c.`divvar'  "\small{$ Dividends_{Season} \times Low \, literacy \times Post$}" ///
							  1.informative#1.post#c.`divvar' "\small{$ Dividends_{Season} \times Informative \times Post$}")	
					
					
					
					
					
					

***************************************
* Table VI: Decay effects
***************************************

cls
use anon_mainsample, replace
drop if year==2019

sort rfs_id wofd
xtset rfs_id wofd
	
	est clear
	eststo e3:	reghdfe buy_transaction_volume_nw  		 	   c.dividends_cutoff##treated##i.year monthly_holdings, abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"


	eststo e4:	reghdfe transaction_volume  			 	   c.dividends_cutoff##treated##i.year   monthly_holdings , abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"

	
	
local divvar "dividends_ws18_21"
	
	eststo e1:	reghdfe buy_transaction_volume_nw  		 	 c.`divvar'##treated##i.year   c.dividends_notws18_21##treated##i.year monthly_holdings, abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"


	eststo e2:	reghdfe transaction_volume  			 	c.`divvar'##treated##i.year   c.dividends_notws18_21##treated##i.year   monthly_holdings , abs(wofd rfs_id) cluster(rfs_id)
	estadd local divfe "Y"
	estadd local control "Y"
	
	
	
esttab e4  e2 e3  e1 ,   ///
					replace b(2) se star(* 0.10 ** 0.05 *** 0.01) nogaps label substitute(_ _)  ///
					keep(1.treated#*.year#c.dividends_cutoff 1.treated#*.year#c.`divvar' 1.treated#*.year#c.dividends_notws18_21) ///
					order(1.treated#*.year#c.dividends_cutoff 1.treated#*.year#c.`divvar' 1.treated#*.year#c.dividends_notws18_21) ///
					drop(*2020.year*) ///
					stats( divfe control r2 N, fmt(%15.2fc %15.2fc %15.2fc %15.0fc %15.0fc) ///
					labels("Individual FE" "Controls" "R-squared" "Observations" "Preperiod mean y" "Preperiod mean x"  )) nonotes  ///
					mgroups("\shortstack{Net transactions}" ///
							"\shortstack{Purchases}", ///
							pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) ///
							span erepeat(\cmidrule(lr){@span})) ///
					width(\hsize) ///
					booktabs ///
					obslast nomtitles ///
					refcat(1.group "", nolabel) ///
					varlabels(1.treated#2021.year#c.dividends_cutoff "$ Dividends_{All} \times Treatment \times 2021" ///
							  1.treated#2022.year#c.dividends_cutoff "$ Dividends_{All} \times Treatment \times 2022" ///
							  1.treated#2023.year#c.dividends_cutoff "$ Dividends_{All} \times Treatment \times 2023" ///
							  1.treated#2021.year#c.`divvar' "$ Dividends_{Season} \times Treatment \times 2021" ///
							  1.treated#2022.year#c.`divvar' "$ Dividends_{Season} \times Treatment \times 2022" ///
							  1.treated#2023.year#c.`divvar' "$ Dividends_{Season} \times Treatment \times 2023" ///
							  1.treated#2021.year#c.dividends_notws18_21 "$ Dividends_{Other} \times Treatment \times 2021" ///
							  1.treated#2022.year#c.dividends_notws18_21 "$ Dividends_{Other} \times Treatment \times 2022" ///
							  1.treated#2023.year#c.dividends_notws18_21 "$ Dividends_{Other} \times Treatment \times 2023"  )
							  
							  
esttab e4  e2 e3  e1  using tables/Table6.tex ,  ///,  ///
					replace b(2) se star(* 0.10 ** 0.05 *** 0.01) nogaps label substitute(_ _) ///
						keep(1.treated#*.year#c.dividends_cutoff 1.treated#*.year#c.`divvar' 1.treated#*.year#c.dividends_notws18_21) ///
					order(1.treated#*.year#c.dividends_cutoff 1.treated#*.year#c.`divvar' 1.treated#*.year#c.dividends_notws18_21) ///
					drop(*2020.year*) ///
					stats( divfe control r2 N, fmt(%15.2fc %15.2fc %15.2fc %15.0fc %15.0fc) ///
					labels("Individual FE" "Controls" "R-squared" "Observations" "Preperiod mean y" "Preperiod mean x"  )) nonotes  ///
					mgroups("\shortstack{Net transactions}" ///
							"\shortstack{Purchases}", ///
							pattern(1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) ///
							span erepeat(\cmidrule(lr){@span})) ///
					width(\hsize) ///
					booktabs ///
					obslast nomtitles ///
					refcat(1.group "", nolabel) ///
					varlabels(1.treated#2021.year#c.dividends_cutoff "$ Dividends_{All} \times Treatment \times 2021" ///
							  1.treated#2022.year#c.dividends_cutoff "$ Dividends_{All} \times Treatment \times 2022" ///
							  1.treated#2023.year#c.dividends_cutoff "$ Dividends_{All} \times Treatment \times 2023" ///
							  1.treated#2021.year#c.`divvar' "$ Dividends_{Season} \times Treatment \times 2021" ///
							  1.treated#2022.year#c.`divvar' "$ Dividends_{Season} \times Treatment \times 2022" ///
							  1.treated#2023.year#c.`divvar' "$ Dividends_{Season} \times Treatment \times 2023" ///
							  1.treated#2021.year#c.dividends_notws18_21 "$ Dividends_{Other} \times Treatment \times 2021" ///
							  1.treated#2022.year#c.dividends_notws18_21 "$ Dividends_{Other} \times Treatment \times 2022" ///
							  1.treated#2023.year#c.dividends_notws18_21 "$ Dividends_{Other} \times Treatment \times 2023"  )
							  
	
	
	
	
***************************************************************************************************
* Table VII: dividend yield
***************************************************************************************************

*use detailed_trans, replace
// FILE IS NOT INCLUDED IN REPLCIATION PACKAGE //
merge m:1 rfs_id using anon_mainsample 
keep if _m==3


eststo e1: reghdfe divyield			treated##post , abs(hof ym) cluster(rfs_id)
eststo e2: reg divyield_buy 		treated, cluster(rfs_id)
eststo e3: reg divyield_buy_new 	treated, cluster(rfs_id)


											
esttab e1 e2 e3  using tables/Table7.tex,      keep(*1.treated#1.post* treated) order(*1.treated#1.post*)  style(tex) replace b(2) se star(* 0.10 ** 0.05 *** 0.01) noobs                varwidth(25) 	///
						mgroups("\shortstack{Yield portfolio}" "\shortstack{Yield purchases}" "\shortstack{Yield new purchases}", pattern(1  1  1) prefix(\multicolumn{@span}{c}{) suffix(}) ///
													span erepeat(\cmidrule(lr){@span})) ///
													booktabs ///
											obslast nomtitles ///
											width(\hsize) ///
											refcat(1.group "", nolabel) ///
											varlabels(1.treated#1.post "$ Treatment \times Post$ " ///
											treated "$ Treatment $ ")

											
	exit



	